<template>
  <div class="wx_loginBox">
    <!-- logo -->
    <div class="img">
      <img
        src="https://msmk2019.oss-cn-shanghai.aliyuncs.com/uploads/image/2019pILfAg7Avr1567732916.png"
        alt
      />
    </div>
    <!-- 登录区域 -->
    <input type="text" v-model="phone" placeholder="请输入手机号" />
    <input type="password" v-model="password" placeholder="请输入密码" />
    <!-- 找回密码 -->
    <div class="flex">
      <router-link to="/findPassword" tag="div" class="div1">找回密码</router-link>
      <router-link class="div2" to="/smsLogin" tag="div">注册/验证码登录</router-link>
    </div>
    <!-- 登录 -->
    <div >
      <van-button class="login" color="#fd6b19" size="large" type="warning" @click="login1">登录</van-button>
    </div>
    
  </div>
</template>

<script>
import {login2} from '@/request/http.js'
import { Button} from "vant";
export default {
  data(){
    return{
      phone:'', //绑定的手机号
      password:'123456789', //密码
    }
  },
  methods:{
    // 1 点击登录按钮
    login1(){
      //判断手机号和密码不能为空
      if(this.phone == "" || this.password==""){
        window.alert("格式错误")
      }
      login2(
        this.phone,
        this.password,
        1, // 账号密码登录type：1
        1, // 学生端client：1

      ).then(res=>{
        console.log(res)
        // 存储token
        this.$store.commit("add",res)
         localStorage.setItem('adminToken',res.remember_token)
        this.$router.push('/index')
      })
    }
  },
   components: {
    [Button.name]: Button,
  },
  
};
</script>

<style scoped lang="scss">
.wx_loginBox {
  // line-height: 50px;
  background: white;
   position: relative;
  min-height:850px; 
  .img {
    width: 60%;
    margin: 0 auto;
    padding: 15%;
    img {
      width: 100%;
    }
  }
  input {
    width: 98%;
    border: none;
    margin: 10px 0;
    height: 30px;
    font-size: 14px;
    color: #c0c0c0;
    box-sizing: border-box;
    padding-left: 40px;
  }

  .flex {
    display: flex;
    margin-top: 10px;
    justify-content: space-between;
    width: 94%;
    padding: 0 3%;
    color: gray;
    .div1 {
      font-size: 12px;
      box-sizing: border-box;
      padding-left: 30px;
    }
    .div2{
      font-size: 12px;
      box-sizing: border-box;
      padding-right: 30px;
    }
   
  }

  .login {
    width: 80%;
    min-height: 50px;
    position: absolute;
    bottom: 30%;
    left: 10%;
    text-align: center;
    border-radius: 30px;
    overflow: hidden;
  }
}
</style>